home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Misc / bgui / Examples / Source / DemoCode.h < prev    next >
C/C++ Source or Header  |  2000-05-09  |  3KB  |  159 lines

  1. /*
  2.  * @(#) $Header: /cvsroot/bgui/examples/DemoCode.h,v 41.11 2000/05/09 20:33:28 mlemos Exp $
  3.  *
  4.  * DemoCode.h
  5.  *
  6.  * (C) Copyright 1998 Manuel Lemos.
  7.  * (C) Copyright 1995 Jaba Development.
  8.  * (C) Copyright 1995 Jan van den Baard.
  9.  * All Rights Reserved.
  10.  *
  11.  * $Log: DemoCode.h,v $
  12.  * Revision 41.11  2000/05/09 20:33:28  mlemos
  13.  * Bumped to revision 41.11
  14.  *
  15.  * Revision 1.2  2000/05/09 19:58:47  mlemos
  16.  * Merged with the branch Manuel_Lemos_fixes.
  17.  *
  18.  * Revision 1.1.2.2  1999/02/19 05:03:50  mlemos
  19.  * Added support to build with Storm C.
  20.  *
  21.  * Revision 1.1.2.1  1998/02/28 17:45:49  mlemos
  22.  * Ian sources
  23.  *
  24.  *
  25.  */
  26.  
  27. #include <exec/types.h>
  28. #include <exec/memory.h>
  29. #include <dos/dos.h>
  30. #include <libraries/gadtools.h>
  31. #include <libraries/bgui.h>
  32. #include <libraries/bgui_macros.h>
  33. #include <intuition/sghooks.h>
  34. #ifndef __STORM__
  35. #include <graphics/gfxmacros.h>
  36. #endif
  37. #include <workbench/workbench.h>
  38. #include <workbench/startup.h>
  39.  
  40. #include <clib/alib_protos.h>
  41.  
  42. #include <proto/exec.h>
  43. #include <proto/intuition.h>
  44. #include <proto/dos.h>
  45. #include <proto/bgui.h>
  46. #include <proto/graphics.h>
  47. #include <proto/diskfont.h>
  48. #include <proto/utility.h>
  49.  
  50. #ifdef __STORM__
  51. #include <graphics/gfxmacros.h>
  52. #endif
  53.  
  54. #include <stdlib.h>
  55.  
  56. #ifdef _DCC
  57. #define SAVEDS __geta4
  58. #define ASM
  59. #define REG(x) __ ## x
  60. #define CHIP(t) __chip t
  61. #elif __STORM__
  62. #define CHIP(t) __chip t
  63. #ifndef SAVEDS
  64. #define SAVEDS  __saveds
  65. #endif
  66. #ifndef ASM
  67. #define ASM
  68. #endif
  69. #ifndef REG
  70. #define REG(x) register __ ## x
  71. #endif
  72. #else
  73. #define SAVEDS __saveds
  74. #define ASM __asm
  75. #define REG(x) register __ ## x
  76. #define CHIP(t) t chip
  77. #endif
  78.  
  79. /*
  80.  * The entry point of all demo programs.
  81.  */
  82. extern VOID StartDemo( void );
  83.  
  84. /*
  85.  * Output file handle and BGUI
  86.  * library base.
  87.  */
  88. BPTR     StdOut;
  89. struct Library *BGUIBase;
  90.  
  91. /*
  92.  * Output text to the CLI or Workbench console.
  93.  */
  94. VOID Tell( UBYTE *fstr, ... )
  95. {
  96.    if ( StdOut ) VFPrintf( StdOut, fstr, ( ULONG * )&fstr + 1 );
  97. }
  98.  
  99. /*
  100.  * Main entry point.
  101.  */
  102. int main( int argc, char **argv )
  103. {
  104.    struct Process       *this_task = ( struct Process * )FindTask( NULL );
  105.    BOOL            is_wb = FALSE;
  106.  
  107.    if ( this_task->pr_CLI )
  108.       /*
  109.        * Started from the CLI. Simply pickup
  110.        * the CLI output handle.
  111.        */
  112.       StdOut = Output();
  113.    else {
  114.       /*
  115.        * Workbench startup. Open a console
  116.        * for output.
  117.        */
  118.       StdOut = Open( "CON:10/10/500/100/BGUI Demo Output/WAIT/AUTO", MODE_NEWFILE );
  119.       is_wb = TRUE;
  120.    }
  121.  
  122.    /*
  123.     * Open BGUI.
  124.     */
  125.    if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
  126.       /*
  127.        * Run the demo.
  128.        */
  129.       StartDemo();
  130.       CloseLibrary( BGUIBase );
  131.    } else
  132.       Tell( "Unable to open %s version %ld\n", BGUINAME, BGUIVERSION );
  133.  
  134.    /*
  135.     * Close console if ran from
  136.     * the workbench.
  137.     */
  138.    if ( is_wb ) {
  139.       if ( StdOut ) Close( StdOut );
  140.    }
  141.  
  142.    return( 0 );
  143. }
  144.  
  145. /*
  146.  * DICE stub which simply calls
  147.  * main() when run from the
  148.  * workbench.
  149.  */
  150. #if _DCC || __STORM__
  151. int wbmain( struct WBStartup *wbs )
  152. {
  153.    return( main( NULL, 0 ));
  154. }
  155. #endif
  156.  
  157. #define FuzzButton(label,id) ButtonObject, LAB_Label, label, LAB_Underscore, '_',\
  158.    GA_ID, id, FuzzButtonFrame, EndObject
  159.